<template>
  <div class="mod-config">
    <table-view ref="view"
                :searchAttrs="searchAttrs"
                :primaryKey="primaryKey"
                :listApiName="listApiName"
                :deleteApiName="deleteApiName"
                :saveAuthName="saveAuthName"
                :deleteAuthName="deleteAuthName"
                :showAttrs="showAttrs"
                :exportApiName="exportApiName"
    >
    </table-view>
    <add-or-update v-if="addOrUpdateVisible" ref="addOrUpdate" @refreshDataList="getDataList"></add-or-update>
    <product-info-add-or-update v-if="productInfoVisible" ref="productInfo"></product-info-add-or-update>

  </div>
</template>

<script>
import AddOrUpdate from './ordermodel-add-or-update'
import tableView from '@/components/tableView'
import basicMixins from '@/utils/commonViewMixins'
import ProductInfoAddOrUpdate  from '@/views/modules/product/productinfo-add-or-update'

export default {
  mixins: [basicMixins],
  data() {
    return {
      searchAttrs: {
        clientId: {
          label: '客户名称',
          clearable: true,
          type: 'autoComplete',
          placeholder: '请输入客户名称',
          querySearchApiName: 'clientApi/getClientList'
        },
        productId: {
          label: '产品名称',
          clearable: true,
          type: 'autoComplete',
          placeholder: '请输入产品名称',
          querySearchApiName: 'orderApi/getOrderModelProductList'
        },
        dateTimeRange: {
          type: 'date',
          dateType: 'daterange',
          clearable: true
        }

      },
      showAttrs: {
        clientContractNo:{
          label: '客户合同编号'
        },
        clientName: {label: '客户名称'},
        productNo: {label: '产品名称'},
        userName: {label: '业务'},
        modelNo: {label: '模具编号'},
        modelType: {label: '生产/试样模',
          type: 'radio',
          items: [
            {value: 0, text: '试样模', tagType: 'info'},
            {value: 1, text: '生产模'}
          ]},
        unitPrice: {label: '价格'},
        localProduct: {
          label: '在供应商做大货',
          type: 'radio',
          items: [
            {value: 0, text: '不在', tagType: 'danger'},
            {value: 1, text: '在'}
          ]
        },
        successMo: {label: '成模'},
        primaryMo: {label: '初模'},
        menTou: {label: '闷头'},
        louDou: {label: '漏斗'},
        kouZi: {label: '口子'},
        xinZi: {label: '芯子'},
        qiTou: {label: '气头'},
        jiaZi: {label: '夹子'},
        qianPian: {label: '钳片'},
        lengQue: {label: '冷却'},
        bottomMo: {label: '底模'},
        modelCategoryName: {label: '模具类别'},
        dayTime: {label: '日期', type: 'date',width:120},
        remark: {label: '备注'},
        updateUser:{
          label: '采购审核',
          type: 'radio',
          items: [
            {value: 38, text: '已审核', tagType: 'success'},
          ]
        },
        status: {
          label: '状态',
          type: 'radio',
          items: [
            {value: 0, text: '禁用', tagType: 'danger'},
            {value: 1, text: '正常'}
          ]
        }
      },
      productInfoVisible: false,
      primaryKey: 'id',
      listApiName: 'orderApi/listOrderModel',
      deleteApiName: 'orderApi/deleteOrderModel',
      saveAuthName: 'order:ordermodel:save',
      deleteAuthName: 'order:ordermodel:delete',
      exportApiName:'orderApi/getOrderModelListExport'
    }
  },
  components: {
    AddOrUpdate,
    ProductInfoAddOrUpdate,
    tableView
  },
  methods:{
    openProductInfoDialog(cb) {
      this.productInfoVisible = true
      this.$nextTick(() => {
        if (!this.R.isNil(this.$refs.productInfo)) {
          this.$refs.productInfo.init(null, {status: 1}, cb)
        }
      })
    }
  }
}
</script>
